package lzzy;

import java.io.*;

public class TestFileStream {
    public static void main(String[] args) throws IOException{
        try(
            // 创建文件的输出流
            FileOutputStream output = new FileOutputStream("temp.dat");
        )  {
            // 将值输出到文件
            for (int i = 1; i <= 10; i++)
                output.write(i);
        }

        try(
            // 创建文件的输入流
            FileInputStream input = new FileInputStream("temp.dat");
        )  {
            // 从文件中读取值
            int value;
            while((value = input.read()) != -1)
                System.out.print(value + " ");
        }
    }
}

